package org.example.web_demo1.exception;

import org.example.web_demo1.entity.ErrorResult;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class BaseAdvice {


    @ExceptionHandler(value = Exception.class)
    public ErrorResult exception(Exception e) {
        ErrorResult error = new ErrorResult();
        error.setCode(501);
        error.setMessage(e.getMessage());
        return error;
    }


}
